module Yarbo::Controllers

  class Blog < R '/'
    
    def get
      
    end
    
    def post
    end
    
  end
  
  
  class Themes < R '/themes/(.+)'         
    MIME_TYPES = {'.css' => 'text/css', '.js' => 'text/javascript', 
                  '.jpg' => 'image/jpeg', '.png' => 'image/png',
                  '.gif' => 'image/gif'}
    PATH = Yarbo::Conf.themes_dir || File.expand_path(File.dirname(__FILE__))+'/../themes'

    def get(path)
      @headers['Content-Type'] = MIME_TYPES[path[/\.\w+$/, 0]] || "text/plain"
      unless path.include? ".." # prevent directory traversal attacks
        @headers['X-Sendfile'] = "#{PATH}/#{path}"
      else
        @status = "403"
        "403 - Invalid path"
      end
    end
  end
end
